package com.tanhua.server.controller;

import com.tanhua.server.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author lk
 * @date 2022-04-01
 */
@RestController
@RequestMapping("/baidu")
public class BaiduController {

    @Autowired
    private BaiduService baiduService;

    //更新地理位置信息
    @PostMapping("/location")
    public ResponseEntity updateLocation(@RequestBody Map map){
        //获取经度
        Double longitude = Double.valueOf(map.get("longitude").toString());
        //获取维度
        Double latitude = Double.valueOf(map.get("latitude").toString());
        //获取地址信息
        String addrStr = map.get("addrStr").toString();
        baiduService.updateLocation(longitude,latitude,addrStr);
        return ResponseEntity.ok(null);
    }


}
